<!DOCTYPE html>



  


<html class="theme-next muse use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.3" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon.png?v=5.1.3">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32.png?v=5.1.3">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16.png?v=5.1.3">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.3" color="#222">





  <meta name="keywords" content="bbr,tcp," />





  <link rel="alternate" href="/atom.xml" title="大牙的杂货铺" type="application/atom+xml" />






<meta name="description" content="BBR简述 Google 开源了其 TCP BBR 拥塞控制算法，并提交到了 Linux 内核，从 4.9 开始，Linux 内核已经用上了该算法。 目的是要尽量跑满带宽，并且尽量不要有排队的情况。 可以起到单边加速TCP连接的效果。 TCP BBR致力于解决两个问题 在有一定丢包率的网络链路上充分利用带宽 降低网络链">
<meta name="keywords" content="bbr,tcp">
<meta property="og:type" content="article">
<meta property="og:title" content="让谷歌TCP-BBR拥塞算法为TCP加速">
<meta property="og:url" content="http://linuxgeeks.github.io/2017/12/24/2017-12-24-110110-让谷歌TCP-BBR拥塞算法为TCP加速/index.html">
<meta property="og:site_name" content="大牙的杂货铺">
<meta property="og:description" content="BBR简述 Google 开源了其 TCP BBR 拥塞控制算法，并提交到了 Linux 内核，从 4.9 开始，Linux 内核已经用上了该算法。 目的是要尽量跑满带宽，并且尽量不要有排队的情况。 可以起到单边加速TCP连接的效果。 TCP BBR致力于解决两个问题 在有一定丢包率的网络链路上充分利用带宽 降低网络链路上的 buffer 占用率，从而降低延迟    BBR算法的优势 https:">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2018-01-30T14:14:04.946Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="让谷歌TCP-BBR拥塞算法为TCP加速">
<meta name="twitter:description" content="BBR简述 Google 开源了其 TCP BBR 拥塞控制算法，并提交到了 Linux 内核，从 4.9 开始，Linux 内核已经用上了该算法。 目的是要尽量跑满带宽，并且尽量不要有排队的情况。 可以起到单边加速TCP连接的效果。 TCP BBR致力于解决两个问题 在有一定丢包率的网络链路上充分利用带宽 降低网络链路上的 buffer 占用率，从而降低延迟    BBR算法的优势 https:">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Muse',
    version: '5.1.3',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":true},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://linuxgeeks.github.io/2017/12/24/2017-12-24-110110-让谷歌TCP-BBR拥塞算法为TCP加速/"/>





  <title>让谷歌TCP-BBR拥塞算法为TCP加速 | 大牙的杂货铺</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>
	
	<a href="https://github.com/mengdaya"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/38ef81f8aca64bb9a64448d0d70f1308ef5341ab/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"></a>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">大牙的杂货铺</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-commonweal">
          <a href="/404/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-heartbeat"></i> <br />
            
            公益404
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  <div class="popup search-popup local-search-popup">
  <div class="local-search-header clearfix">
    <span class="search-icon">
      <i class="fa fa-search"></i>
    </span>
    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
    <div class="local-search-input-wrapper">
      <input autocomplete="off"
             placeholder="搜索..." spellcheck="false"
             type="text" id="local-search-input">
    </div>
  </div>
  <div id="local-search-result"></div>
</div>



    </div>
  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://linuxgeeks.github.io/2017/12/24/2017-12-24-110110-让谷歌TCP-BBR拥塞算法为TCP加速/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="孟庆宇">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="大牙的杂货铺">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">让谷歌TCP-BBR拥塞算法为TCP加速</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-12-24T11:01:10+08:00">
                2017-12-24
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/配置/" itemprop="url" rel="index">
                    <span itemprop="name">配置</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          
            <span class="post-meta-divider">|</span>
            <span class="page-pv"><i class="fa fa-file-o"> 本文总阅读量</i>
            <span class="busuanzi-value" id="busuanzi_value_page_pv" ></span>次
            </span>
          

          
            <div class="post-wordcount">
              
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  1,474
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  9
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h3 id="BBR简述"><a href="#BBR简述" class="headerlink" title="BBR简述"></a>BBR简述</h3><ul>
<li>Google 开源了其 TCP BBR 拥塞控制算法，并提交到了 Linux 内核，从 4.9 开始，Linux 内核已经用上了该算法。</li>
<li>目的是要尽量跑满带宽，并且尽量不要有排队的情况。</li>
<li>可以起到单边加速TCP连接的效果。</li>
<li>TCP BBR致力于解决两个问题<ul>
<li>在有一定丢包率的网络链路上充分利用带宽</li>
<li>降低网络链路上的 buffer 占用率，从而降低延迟</li>
</ul>
</li>
</ul>
<h3 id="BBR算法的优势"><a href="#BBR算法的优势" class="headerlink" title="BBR算法的优势"></a>BBR算法的优势</h3><ul>
<li><a href="https://www.zhihu.com/question/53559433" target="_blank" rel="noopener">https://www.zhihu.com/question/53559433</a></li>
</ul>
<h3 id="一键配置脚本"><a href="#一键配置脚本" class="headerlink" title="一键配置脚本"></a>一键配置脚本</h3><ul>
<li>用于CentOS系列6、7版本的系统</li>
<li>脚本自动升级内核使用yum安装，可能下载较慢，可手动下载rpm包</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br><span class="line">210</span><br><span class="line">211</span><br><span class="line">212</span><br><span class="line">213</span><br><span class="line">214</span><br><span class="line">215</span><br><span class="line">216</span><br><span class="line">217</span><br><span class="line">218</span><br><span class="line">219</span><br><span class="line">220</span><br><span class="line">221</span><br><span class="line">222</span><br><span class="line">223</span><br><span class="line">224</span><br><span class="line">225</span><br><span class="line">226</span><br><span class="line">227</span><br><span class="line">228</span><br><span class="line">229</span><br><span class="line">230</span><br><span class="line">231</span><br><span class="line">232</span><br><span class="line">233</span><br><span class="line">234</span><br><span class="line">235</span><br><span class="line">236</span><br><span class="line">237</span><br><span class="line">238</span><br><span class="line">239</span><br><span class="line">240</span><br><span class="line">241</span><br><span class="line">242</span><br><span class="line">243</span><br><span class="line">244</span><br><span class="line">245</span><br><span class="line">246</span><br><span class="line">247</span><br><span class="line">248</span><br><span class="line">249</span><br><span class="line">250</span><br><span class="line">251</span><br><span class="line">252</span><br><span class="line">253</span><br><span class="line">254</span><br><span class="line">255</span><br><span class="line">256</span><br><span class="line">257</span><br><span class="line">258</span><br><span class="line">259</span><br><span class="line">260</span><br><span class="line">261</span><br><span class="line">262</span><br><span class="line">263</span><br><span class="line">264</span><br><span class="line">265</span><br><span class="line">266</span><br><span class="line">267</span><br><span class="line">268</span><br><span class="line">269</span><br><span class="line">270</span><br><span class="line">271</span><br><span class="line">272</span><br><span class="line">273</span><br><span class="line">274</span><br><span class="line">275</span><br><span class="line">276</span><br><span class="line">277</span><br><span class="line">278</span><br><span class="line">279</span><br><span class="line">280</span><br><span class="line">281</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#!/usr/bin/env bash</span></span><br><span class="line">:&lt;&lt;:</span><br><span class="line">------------------------------------------------</span><br><span class="line">       FileName : google_bbr_centos.sh</span><br><span class="line">         Author : Li Tingjie</span><br><span class="line">    Create Time : 2017-05-09 15:09:16</span><br><span class="line">  Last modified : 2017-11-26 17:56:25</span><br><span class="line">           Mail : 2234351300@qq.com</span><br><span class="line">        Version : 0.0.1</span><br><span class="line">    Description :</span><br><span class="line">      CopyRight :</span><br><span class="line">------------------------------------------------</span><br><span class="line">:</span><br><span class="line"></span><br><span class="line"><span class="comment"># Set up a default search path.</span></span><br><span class="line">PATH=<span class="string">"/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin"</span></span><br><span class="line"><span class="built_in">export</span> PATH</span><br><span class="line"></span><br><span class="line"><span class="comment"># Make sure umask is sane</span></span><br><span class="line"><span class="built_in">umask</span> 022</span><br><span class="line"></span><br><span class="line"><span class="comment"># terminal sequence to set color to a 'success' color (currently: green)</span></span><br><span class="line">SETCOLOR_SUCCESS=<span class="string">"echo -en \\033[0;32m"</span></span><br><span class="line"><span class="comment"># terminal sequence to set color to a 'failure' color (currently: red)</span></span><br><span class="line">SETCOLOR_FAILURE=<span class="string">"echo -en \\033[0;31m"</span></span><br><span class="line"><span class="comment"># terminal sequence to set color to a 'warning' color (currently: yellow)</span></span><br><span class="line">SETCOLOR_WARNING=<span class="string">"echo -en \\033[0;33m"</span></span><br><span class="line"><span class="comment"># terminal sequence to reset to the default color.</span></span><br><span class="line">SETCOLOR_NORMAL=<span class="string">"echo -en \\033[0;39m"</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># Log that something succeeded</span></span><br><span class="line"><span class="function"><span class="title">echo_info</span></span>()&#123;</span><br><span class="line">    <span class="built_in">echo</span> -en <span class="string">"[ "</span>;</span><br><span class="line">    <span class="variable">$&#123;SETCOLOR_SUCCESS&#125;</span>;</span><br><span class="line">    <span class="built_in">echo</span> -en <span class="string">" Info "</span>;</span><br><span class="line">    <span class="variable">$&#123;SETCOLOR_NORMAL&#125;</span>;</span><br><span class="line">    <span class="built_in">echo</span> -en <span class="string">" ]  "</span>;</span><br><span class="line">    <span class="built_in">echo</span> <span class="string">"<span class="variable">$@</span>"</span></span><br><span class="line">&#125;</span><br><span class="line"><span class="comment"># Log that something Error</span></span><br><span class="line"><span class="function"><span class="title">echo_error</span></span>()&#123;</span><br><span class="line">    <span class="built_in">echo</span> -en <span class="string">"[ "</span>;</span><br><span class="line">    <span class="variable">$&#123;SETCOLOR_FAILURE&#125;</span>;</span><br><span class="line">    <span class="built_in">echo</span> -en <span class="string">" Error "</span>;</span><br><span class="line">    <span class="variable">$&#123;SETCOLOR_NORMAL&#125;</span>;</span><br><span class="line">    <span class="built_in">echo</span> -en <span class="string">" ]  "</span>;</span><br><span class="line">    <span class="built_in">echo</span> <span class="string">"<span class="variable">$@</span>"</span></span><br><span class="line">&#125;</span><br><span class="line"><span class="comment"># Log a warning</span></span><br><span class="line"><span class="function"><span class="title">echo_warning</span></span>()&#123;</span><br><span class="line">    <span class="built_in">echo</span> -en <span class="string">"[ "</span>;</span><br><span class="line">    <span class="variable">$&#123;SETCOLOR_WARNING&#125;</span>;</span><br><span class="line">    <span class="built_in">echo</span> -en <span class="string">" Warning "</span>;</span><br><span class="line">    <span class="variable">$&#123;SETCOLOR_NORMAL&#125;</span>;</span><br><span class="line">    <span class="built_in">echo</span> -en <span class="string">" ]  "</span>;</span><br><span class="line">    <span class="built_in">echo</span> <span class="string">"<span class="variable">$@</span>"</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="title">bbr_sysctl_config</span></span>()&#123;</span><br><span class="line">    sed -i <span class="string">'/net.core.default_qdisc/d'</span> /etc/sysctl.conf</span><br><span class="line">    sed -i <span class="string">'/net.ipv4.tcp_congestion_control/d'</span> /etc/sysctl.conf</span><br><span class="line">    <span class="built_in">echo</span> <span class="string">"net.core.default_qdisc = fq"</span> &gt;&gt; /etc/sysctl.conf</span><br><span class="line">    <span class="built_in">echo</span> <span class="string">"net.ipv4.tcp_congestion_control = bbr"</span> &gt;&gt; /etc/sysctl.conf</span><br><span class="line">    sysctl -p &gt;/dev/null 2&gt;&amp;1</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="title">get_os</span></span>() &#123;</span><br><span class="line">    [ -f /etc/redhat-release ] &amp;&amp; awk <span class="string">'&#123;print ($1,$3~/^[0-9]/?$3:$4)&#125;'</span> /etc/redhat-release &amp;&amp; <span class="built_in">return</span></span><br><span class="line">    [ -f /etc/os-release ] &amp;&amp; awk -F<span class="string">'[= "]'</span> <span class="string">'/PRETTY_NAME/&#123;print $3,$4,$5&#125;'</span> /etc/os-release &amp;&amp; <span class="built_in">return</span></span><br><span class="line">    [ -f /etc/lsb-release ] &amp;&amp; awk -F<span class="string">'[="]+'</span> <span class="string">'/DESCRIPTION/&#123;print $2&#125;'</span> /etc/lsb-release &amp;&amp; <span class="built_in">return</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="title">get_char</span></span>() &#123;</span><br><span class="line">    SAVEDSTTY=`stty -g`</span><br><span class="line">    stty -<span class="built_in">echo</span></span><br><span class="line">    stty cbreak</span><br><span class="line">    dd <span class="keyword">if</span>=/dev/tty bs=1 count=1 2&gt; /dev/null</span><br><span class="line">    stty -raw</span><br><span class="line">    stty <span class="built_in">echo</span></span><br><span class="line">    stty <span class="variable">$SAVEDSTTY</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">clear</span><br><span class="line"><span class="built_in">echo</span> <span class="string">"------------- System Information --------------"</span></span><br><span class="line"><span class="built_in">echo</span></span><br><span class="line"><span class="built_in">echo</span> <span class="string">"          OS : <span class="variable">$(get_os)</span>"</span></span><br><span class="line"><span class="built_in">echo</span> <span class="string">"        Arch : <span class="variable">$(uname -m)</span> <span class="variable">$(getconf LONG_BIT)</span> Bit"</span></span><br><span class="line"><span class="built_in">echo</span> <span class="string">"      Kernel : <span class="variable">$(uname -r)</span>"</span></span><br><span class="line"><span class="built_in">echo</span></span><br><span class="line"><span class="built_in">echo</span> <span class="string">"-----------------------------------------------"</span></span><br><span class="line"><span class="built_in">echo</span> <span class="string">" Auto upgrade latest kernel and turn on TCP BBR"</span></span><br><span class="line"><span class="built_in">echo</span> <span class="string">"-----------------------------------------------"</span></span><br><span class="line"><span class="built_in">echo</span></span><br><span class="line"><span class="built_in">echo</span> <span class="string">"Press any key to start...or Press Ctrl+C to cancel"</span></span><br><span class="line">char=$(get_char)</span><br><span class="line"><span class="built_in">echo</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment">#------------------------------------------------</span></span><br><span class="line"><span class="comment"># Test the operator is root or not</span></span><br><span class="line"><span class="comment">#------------------------------------------------</span></span><br><span class="line"><span class="keyword">if</span> <span class="built_in">test</span> <span class="string">"<span class="variable">$&#123;EUID&#125;</span>"</span> -ne 0 -o <span class="string">"<span class="variable">$&#123;USER&#125;</span>"</span> != <span class="string">"root"</span>;<span class="keyword">then</span></span><br><span class="line">    echo_error <span class="string">"Only root can run this script ... "</span></span><br><span class="line">    <span class="built_in">exit</span> 5</span><br><span class="line"><span class="keyword">else</span></span><br><span class="line">    echo_info <span class="string">"Operator is root "</span></span><br><span class="line"><span class="keyword">fi</span></span><br><span class="line"><span class="comment">#************************************************</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment">#------------------------------------------------  </span></span><br><span class="line"><span class="comment"># Check network is rechable or not</span></span><br><span class="line"><span class="comment">#------------------------------------------------</span></span><br><span class="line">dstname=<span class="string">"www.baidu.com"</span></span><br><span class="line"><span class="keyword">if</span> (ping <span class="variable">$&#123;dstname&#125;</span> -c 3 -i 0.01 -w 2 -q 1&gt;/dev/null 2&gt;&amp;1)<span class="keyword">then</span></span><br><span class="line">    echo_info <span class="string">"Network is rechable "</span></span><br><span class="line"><span class="keyword">else</span></span><br><span class="line">    RETVAL=$?</span><br><span class="line">    echo_error <span class="string">"Network is unreachable , please check "</span></span><br><span class="line">    <span class="built_in">exit</span> 5</span><br><span class="line"><span class="keyword">fi</span></span><br><span class="line"><span class="comment">#************************************************</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment">#------------------------------------------------</span></span><br><span class="line"><span class="comment"># Check your OS is Redhat release or not </span></span><br><span class="line"><span class="comment">#------------------------------------------------</span></span><br><span class="line">rla=<span class="string">"<span class="variable">$(egrep -i "centos|red hat|redhat" /etc/issue)</span>"</span></span><br><span class="line">rlb=<span class="string">"<span class="variable">$(egrep -i "centos|red hat|redhat" /proc/version)</span>"</span></span><br><span class="line"><span class="keyword">if</span> [ -f /etc/centos-release -o -n <span class="string">"<span class="variable">$&#123;rla&#125;</span>"</span> -o -n <span class="string">"<span class="variable">$&#123;rlb&#125;</span>"</span> ]; <span class="keyword">then</span></span><br><span class="line">    echo_info <span class="string">"OS is Redhat release"</span> </span><br><span class="line"><span class="keyword">else</span></span><br><span class="line">    echo_error <span class="string">"Only support for CentOS"</span></span><br><span class="line">    <span class="built_in">exit</span> 5</span><br><span class="line"><span class="keyword">fi</span></span><br><span class="line"><span class="comment">#************************************************</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment">#------------------------------------------------</span></span><br><span class="line"><span class="comment"># Check bbr status</span></span><br><span class="line"><span class="comment">#------------------------------------------------</span></span><br><span class="line">conGestion=<span class="string">"<span class="variable">$(set -- $(sysctl -n net.ipv4.tcp_available_congestion_control)</span>;echo <span class="variable">$1</span>)"</span></span><br><span class="line"><span class="comment"># Get the congestion_control from Kernel parameter</span></span><br><span class="line">bbrmodules=<span class="string">"<span class="variable">$(lsmod | fgrep tcp_bbr)</span>"</span></span><br><span class="line"><span class="comment"># Show the status of tcp_bbr module in the Linux Kernel</span></span><br><span class="line"><span class="keyword">if</span> [ <span class="string">"<span class="variable">$&#123;conGestion&#125;</span>"</span> = <span class="string">"bbr"</span> -a -n <span class="string">"<span class="variable">$&#123;bbrmodules&#125;</span>"</span> ];<span class="keyword">then</span></span><br><span class="line">    echo_info <span class="string">"TCP BBR has been installed. Nothing to do..."</span></span><br><span class="line">    <span class="built_in">exit</span> 5</span><br><span class="line"><span class="keyword">fi</span></span><br><span class="line"><span class="comment">#************************************************</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment">#------------------------------------------------</span></span><br><span class="line"><span class="comment"># Check version of kernel is newer or not</span></span><br><span class="line"><span class="comment">#------------------------------------------------</span></span><br><span class="line">kernelRelease=<span class="string">"<span class="variable">$(uname -r)</span>"</span></span><br><span class="line">newORold=$(<span class="built_in">set</span> -- <span class="variable">$&#123;kernelRelease%%-*&#125;</span> 4.9;<span class="built_in">test</span> <span class="string">"<span class="variable">$(echo -e "$1\n$2" | sort -rV | head -1)</span>"</span> == <span class="string">"<span class="variable">$1</span>"</span> &amp;&amp; <span class="built_in">echo</span> newer || <span class="built_in">echo</span> older )</span><br><span class="line"><span class="keyword">if</span> <span class="built_in">test</span> <span class="string">"<span class="variable">$&#123;newORold&#125;</span>"</span> == <span class="string">'newer'</span>;<span class="keyword">then</span></span><br><span class="line">    echo_info <span class="string">"Version of your kernel is greater than 4.9 , directly setting TCP BBR..."</span></span><br><span class="line">    bbr_sysctl_config</span><br><span class="line">    echo_info <span class="string">"Setting TCP BBR ..."</span></span><br><span class="line">    echo_info <span class="string">'Complete ! '</span></span><br><span class="line">    <span class="built_in">exit</span> 5</span><br><span class="line"><span class="keyword">fi</span></span><br><span class="line"><span class="comment">#************************************************</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment">#------------------------------------------------</span></span><br><span class="line"><span class="comment"># Install elrepo</span></span><br><span class="line"><span class="comment">#------------------------------------------------</span></span><br><span class="line">OS_X=<span class="string">"`grep -Po '(?&lt;=\brelease )[\d]' /etc/redhat-release`"</span></span><br><span class="line"><span class="keyword">if</span> <span class="built_in">test</span> ! -z <span class="string">"<span class="variable">$&#123;OS_X//[0-9]/&#125;</span>"</span>;<span class="keyword">then</span></span><br><span class="line">    echo_error <span class="string">"Not available for your system :("</span></span><br><span class="line"><span class="keyword">else</span></span><br><span class="line">    echo_info <span class="string">"Installing elrepo"</span></span><br><span class="line"><span class="keyword">fi</span></span><br><span class="line"></span><br><span class="line">rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org</span><br><span class="line"><span class="keyword">case</span> <span class="variable">$OS_X</span> <span class="keyword">in</span></span><br><span class="line">    6)</span><br><span class="line">        rpm -Uvh http://www.elrepo.org/elrepo-release-6-8.el6.elrepo.noarch.rpm</span><br><span class="line">        ;;</span><br><span class="line">    7)</span><br><span class="line">        rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm</span><br><span class="line">        ;;</span><br><span class="line">    *)</span><br><span class="line">        echo_error <span class="string">"Not support for CentOS<span class="variable">$&#123;OS_X&#125;</span>"</span></span><br><span class="line">        <span class="built_in">exit</span> 5</span><br><span class="line">        ;;</span><br><span class="line"><span class="keyword">esac</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">if</span> [ ! -s /etc/yum.repos.d/elrepo.repo ]; <span class="keyword">then</span></span><br><span class="line">    echo_error <span class="string">"Install elrepo failed , please check "</span></span><br><span class="line">    <span class="built_in">exit</span> 5</span><br><span class="line"><span class="keyword">fi</span></span><br><span class="line"><span class="comment">#************************************************</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment">#------------------------------------------------</span></span><br><span class="line"><span class="comment"># Upgrade kernel</span></span><br><span class="line"><span class="comment">#------------------------------------------------</span></span><br><span class="line">yum --enablerepo=elrepo-kernel -y install kernel-ml kernel-ml-devel</span><br><span class="line"></span><br><span class="line">echo_info <span class="string">"Query package :"</span></span><br><span class="line"><span class="built_in">echo</span> <span class="string">'------------------------------------------------'</span></span><br><span class="line">rpm -qa kernel-ml</span><br><span class="line"><span class="built_in">echo</span> <span class="string">'------------------------------------------------'</span></span><br><span class="line"><span class="built_in">echo</span></span><br><span class="line"><span class="keyword">if</span> [ $? -ne 0 ]; <span class="keyword">then</span></span><br><span class="line">    echo_error <span class="string">"Install latest kernel failed, please check it."</span></span><br><span class="line">    <span class="built_in">exit</span> 5</span><br><span class="line"><span class="keyword">fi</span></span><br><span class="line"><span class="comment">#************************************************</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment">#------------------------------------------------</span></span><br><span class="line"><span class="comment"># config for grub</span></span><br><span class="line"><span class="comment">#------------------------------------------------</span></span><br><span class="line"><span class="keyword">case</span> <span class="variable">$OS_X</span> <span class="keyword">in</span></span><br><span class="line">    6)</span><br><span class="line">        <span class="keyword">if</span> [ ! -s <span class="string">"/boot/grub/grub.conf"</span> ]; <span class="keyword">then</span></span><br><span class="line">            echo_error <span class="string">"/boot/grub/grub.conf wrong, please check it."</span></span><br><span class="line">            <span class="built_in">exit</span> 5</span><br><span class="line">        <span class="keyword">fi</span></span><br><span class="line"></span><br><span class="line">        echo_info <span class="string">"List of kernel that is available"</span></span><br><span class="line">        <span class="built_in">echo</span> <span class="string">'------------------------------------------------'</span></span><br><span class="line">        awk <span class="string">'/title/&#123;$1="";print&#125;'</span> /etc/grub.conf</span><br><span class="line">        <span class="built_in">echo</span> <span class="string">'------------------------------------------------'</span></span><br><span class="line">        <span class="built_in">echo</span> </span><br><span class="line"></span><br><span class="line">        sed -ri <span class="string">'s/^default=.*/default=0/g'</span> /boot/grub/grub.conf</span><br><span class="line">        ;;</span><br><span class="line">    7)</span><br><span class="line">        <span class="keyword">if</span> [ ! -s <span class="string">"/boot/grub2/grub.cfg"</span> ]; <span class="keyword">then</span></span><br><span class="line">            echo_error <span class="string">"/boot/grub2/grub.cfg wrong, please check it."</span></span><br><span class="line">            <span class="built_in">exit</span> 5</span><br><span class="line">        <span class="keyword">fi</span></span><br><span class="line"></span><br><span class="line">        echo_info <span class="string">"List of kernel that is available"</span></span><br><span class="line">        <span class="built_in">echo</span> <span class="string">'------------------------------------------------'</span></span><br><span class="line">        awk -F<span class="string">'[\047]+'</span>  <span class="string">'/^menuentry/&#123;print $2&#125;'</span> /boot/grub2/grub.cfg</span><br><span class="line">        <span class="built_in">echo</span> <span class="string">'------------------------------------------------'</span></span><br><span class="line">        <span class="built_in">echo</span></span><br><span class="line"></span><br><span class="line">        grub_default_kernel=$(awk -F<span class="string">'[\047]+'</span>  <span class="string">'/^menuentry/&#123;print "\047"$2"\047";exit&#125;'</span> /boot/grub2/grub.cfg)</span><br><span class="line">        </span><br><span class="line">        <span class="built_in">echo</span> <span class="string">"grub2-set-default 0"</span></span><br><span class="line">        <span class="built_in">echo</span></span><br><span class="line">        grub2-set-default 0</span><br><span class="line"></span><br><span class="line">        <span class="built_in">echo</span> <span class="string">"grub2-mkconfig -o /boot/grub2/grub.cfg"</span></span><br><span class="line">        <span class="built_in">echo</span></span><br><span class="line">        grub2-mkconfig -o /boot/grub2/grub.cfg</span><br><span class="line">        ;;</span><br><span class="line">    *)</span><br><span class="line">        echo_error <span class="string">"Not support for CentOS<span class="variable">$&#123;OS_X&#125;</span>"</span></span><br><span class="line">        <span class="built_in">exit</span> 5</span><br><span class="line">        ;;</span><br><span class="line"><span class="keyword">esac</span></span><br><span class="line"><span class="comment">#************************************************</span></span><br><span class="line"></span><br><span class="line">bbr_sysctl_config</span><br><span class="line"></span><br><span class="line"><span class="comment">#------------------------------------------------</span></span><br><span class="line"><span class="comment"># Waitting for reboot</span></span><br><span class="line"><span class="comment">#------------------------------------------------</span></span><br><span class="line"><span class="built_in">echo</span></span><br><span class="line">echo_warning <span class="string">"The system needs to reboot."</span></span><br><span class="line"><span class="built_in">echo</span> </span><br><span class="line"><span class="built_in">read</span> -p <span class="string">'Do you want to restart system ? [yes/no] '</span> yesOrno</span><br><span class="line"><span class="keyword">case</span> <span class="string">"<span class="variable">$&#123;yesOrno&#125;</span>"</span> <span class="keyword">in</span></span><br><span class="line">    y|Y|[yY][eE]|[yY][eE][sS])</span><br><span class="line">            reboot</span><br><span class="line">            ;;</span><br><span class="line">    n|N|[nN][oO])</span><br><span class="line">            echo_info <span class="string">"Reboot has been canceled..."</span></span><br><span class="line">            <span class="built_in">exit</span> 5</span><br><span class="line">            ;;</span><br><span class="line"><span class="keyword">esac</span></span><br><span class="line"><span class="comment">#************************************************</span></span><br></pre></td></tr></table></figure>
<h3 id="7系统内核查看"><a href="#7系统内核查看" class="headerlink" title="7系统内核查看"></a>7系统内核查看</h3><ul>
<li>查看可用内核 </li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">awk -F<span class="string">'[\047]+'</span>  <span class="string">'/^menuentry/&#123;print $2&#125;'</span> /boot/grub2/grub.cfg</span><br></pre></td></tr></table></figure>
<ul>
<li>查看当前内核</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">uname -r</span><br></pre></td></tr></table></figure>
<ul>
<li>修改开机时默认使用的内核</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">grub2-set-default <span class="string">'CentOS Linux (4.14.2-1.el7.elrepo.x86_64) 7 (Core)'</span></span><br><span class="line"><span class="comment"># 或使用索引号0、1、2.....</span></span><br><span class="line">grub2-set-default 0</span><br></pre></td></tr></table></figure>
<ul>
<li>查看内核修改结果</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">grub2-editenv list</span><br></pre></td></tr></table></figure>
<ul>
<li>重新生成 grub2 的配置文件</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">grub2-mkconfig -o /boot/grub2/grub.cfg</span><br></pre></td></tr></table></figure>
<ul>
<li><p>grub操作帮助</p>
<ul>
<li><a href="http://fedoraproject.org/wiki/GRUB_2/zh-cn" target="_blank" rel="noopener">http://fedoraproject.org/wiki/GRUB_2/zh-cn</a></li>
</ul>
</li>
</ul>

      
    </div>
    
    
    

    

    
      <div>
        <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
  <div>有钱任性，请我吃包辣条</div>
  <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
    <span>打赏</span>
  </button>
  <div id="QR" style="display: none;">

    
      <div id="wechat" style="display: inline-block">
        <img id="wechat_qr" src="/images/wechatpay.jpg" alt="孟庆宇 微信支付"/>
        <p>微信支付</p>
      </div>
    

    
      <div id="alipay" style="display: inline-block">
        <img id="alipay_qr" src="/images/alipay.jpg" alt="孟庆宇 支付宝"/>
        <p>支付宝</p>
      </div>
    

    

  </div>
</div>

      </div>
    

    
      <div>
        <ul class="post-copyright">
  <li class="post-copyright-author">
    <strong>本文作者：</strong>
    孟庆宇
  </li>
  <li class="post-copyright-link">
    <strong>本文链接：</strong>
    <a href="http://linuxgeeks.github.io/2017/12/24/2017-12-24-110110-让谷歌TCP-BBR拥塞算法为TCP加速/" title="让谷歌TCP-BBR拥塞算法为TCP加速">http://linuxgeeks.github.io/2017/12/24/2017-12-24-110110-让谷歌TCP-BBR拥塞算法为TCP加速/</a>
  </li>
  <li class="post-copyright-license">
    <strong>版权声明： </strong>
    本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/3.0/" rel="external nofollow" target="_blank">CC BY-NC-SA 3.0</a> 许可协议。转载请注明出处！
  </li>
</ul>

      </div>
    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/bbr/" rel="tag"><i class="fa fa-tag"></i> bbr</a>
          
            <a href="/tags/tcp/" rel="tag"><i class="fa fa-tag"></i> tcp</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2017/12/23/2017-12-23-121010-使用safe-rm避免rm命令误删文件/" rel="next" title="使用safe-rm避免rm命令误删文件">
                <i class="fa fa-chevron-left"></i> 使用safe-rm避免rm命令误删文件
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2017/12/25/2017-12-25-121210-使用dig命令写一个定时解析脚本/" rel="prev" title="使用dig命令写一个定时解析脚本">
                使用dig命令写一个定时解析脚本 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
        
  <div class="bdsharebuttonbox">
    <a href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a>
    <a href="#" class="bds_douban" data-cmd="douban" title="分享到豆瓣网"></a>
    <a href="#" class="bds_sqq" data-cmd="sqq" title="分享到QQ好友"></a>
    <a href="#" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a>
    <a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"></a>
    <a href="#" class="bds_tieba" data-cmd="tieba" title="分享到百度贴吧"></a>
    <a href="#" class="bds_twi" data-cmd="twi" title="分享到Twitter"></a>
    <a href="#" class="bds_fbook" data-cmd="fbook" title="分享到Facebook"></a>
    <a href="#" class="bds_more" data-cmd="more"></a>
    <a class="bds_count" data-cmd="count"></a>
  </div>
  <script>
    window._bd_share_config = {
      "common": {
        "bdText": "",
        "bdMini": "2",
        "bdMiniList": false,
        "bdPic": ""
      },
      "share": {
        "bdSize": "16",
        "bdStyle": "0"
      },
      "image": {
        "viewList": ["tsina", "douban", "sqq", "qzone", "weixin", "twi", "fbook"],
        "viewText": "分享到：",
        "viewSize": "16"
      }
    }
  </script>

<script>
  with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='//bdimg.share.baidu.com/static/api/js/share.js?cdnversion='+~(-new Date()/36e5)];
</script>

      
    </div>
  </div>


          </div>
          


          
  


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
      <div id="sidebar-dimmer"></div>
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image"
                src="/images/avatar.jpg"
                alt="孟庆宇" />
            
              <p class="site-author-name" itemprop="name">孟庆宇</p>
              <p class="site-description motion-element" itemprop="description">书山有路勤为径，学海无涯苦作舟</p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">109</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/categories/index.html">
                  <span class="site-state-item-count">23</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/tags/index.html">
                  <span class="site-state-item-count">56</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          
            <div class="feed-link motion-element">
              <a href="/atom.xml" rel="alternate">
                <i class="fa fa-rss"></i>
                RSS
              </a>
            </div>
          

          <div class="links-of-author motion-element">
            
              
                <span class="links-of-author-item">
                  <a href="https://github.com/mengdaya" target="_blank" title="GitHub">
                    
                      <i class="fa fa-fw fa-github"></i>GitHub</a>
                </span>
              
                <span class="links-of-author-item">
                  <a href="mailto:yourname@gmail.com" target="_blank" title="E-Mail">
                    
                      <i class="fa fa-fw fa-envelope"></i>E-Mail</a>
                </span>
              
            
          </div>

          
          

          
          
            <div class="links-of-blogroll motion-element links-of-blogroll-inline">
              <div class="links-of-blogroll-title">
                <i class="fa  fa-fw fa-globe"></i>
                友情链接
              </div>
              <ul class="links-of-blogroll-list">
                
                  <li class="links-of-blogroll-item">
                    <a href="https://www.ibm.com/developerworks/cn/" title="IBM developerWorks" target="_blank">IBM developerWorks</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="http://iissnan.com/progit/" title="Pro Git" target="_blank">Pro Git</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="http://www.freeoa.net/index/" title="freeOA" target="_blank">freeOA</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="http://www.ttlsa.com/" title="运维生存时间" target="_blank">运维生存时间</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="http://www.361way.com/" title="运维之路" target="_blank">运维之路</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="http://www.yiibai.com/" title="易百教程" target="_blank">易百教程</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="http://www.centoscn.com/" title="CentOS中文站" target="_blank">CentOS中文站</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="http://www.linuxprobe.com/" title="Linux就该这么学" target="_blank">Linux就该这么学</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="http://www.netingcn.com/" title="网络进行时" target="_blank">网络进行时</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="http://www.ruanyifeng.com/blog/" title="阮一峰的网络日志" target="_blank">阮一峰的网络日志</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://www.liaoxuefeng.com" title="廖雪峰的官方网站" target="_blank">廖雪峰的官方网站</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://yihui.name/cn/" title="谢益辉的博客" target="_blank">谢益辉的博客</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://coolshell.cn" title="酷壳" target="_blank">酷壳</a>
                  </li>
                
              </ul>
            </div>
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#BBR简述"><span class="nav-number">1.</span> <span class="nav-text">BBR简述</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#BBR算法的优势"><span class="nav-number">2.</span> <span class="nav-text">BBR算法的优势</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#一键配置脚本"><span class="nav-number">3.</span> <span class="nav-text">一键配置脚本</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#7系统内核查看"><span class="nav-number">4.</span> <span class="nav-text">7系统内核查看</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; 2015 &mdash; <span itemprop="copyrightYear">2018</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">文章总结于网络，转载请注明出处</span>

  
</div>









        
<div class="busuanzi-count">
  <script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  
    <span class="site-uv">
      <i class="fa fa-user">本站访客</i>
      <span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
      人
    </span>
  

  
    <span class="site-pv">
      <i class="fa fa-eye">本站总访问量</i>
      <span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
      次
    </span>
  
</div>








        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  


  











  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>

  
  <script type="text/javascript" src="true"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.3"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.3"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.3"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.3"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.3"></script>



  


  




	





  





  








  

  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    var isXml = true;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length === 0) {
      search_path = "search.xml";
    } else if (/json$/i.test(search_path)) {
      isXml = false;
    }
    var path = "/" + search_path;
    // monitor main search box;

    var onPopupClose = function (e) {
      $('.popup').hide();
      $('#local-search-input').val('');
      $('.search-result-list').remove();
      $('#no-result').remove();
      $(".local-search-pop-overlay").remove();
      $('body').css('overflow', '');
    }

    function proceedsearch() {
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay"></div>')
        .css('overflow', 'hidden');
      $('.search-popup-overlay').click(onPopupClose);
      $('.popup').toggle();
      var $localSearchInput = $('#local-search-input');
      $localSearchInput.attr("autocapitalize", "none");
      $localSearchInput.attr("autocorrect", "off");
      $localSearchInput.focus();
    }

    // search function;
    var searchFunc = function(path, search_id, content_id) {
      'use strict';

      // start loading animation
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay">' +
          '<div id="search-loading-icon">' +
          '<i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>' +
          '</div>' +
          '</div>')
        .css('overflow', 'hidden');
      $("#search-loading-icon").css('margin', '20% auto 0 auto').css('text-align', 'center');

      $.ajax({
        url: path,
        dataType: isXml ? "xml" : "json",
        async: true,
        success: function(res) {
          // get the contents from search data
          isfetched = true;
          $('.popup').detach().appendTo('.header-inner');
          var datas = isXml ? $("entry", res).map(function() {
            return {
              title: $("title", this).text(),
              content: $("content",this).text(),
              url: $("url" , this).text()
            };
          }).get() : res;
          var input = document.getElementById(search_id);
          var resultContent = document.getElementById(content_id);
          var inputEventFunction = function() {
            var searchText = input.value.trim().toLowerCase();
            var keywords = searchText.split(/[\s\-]+/);
            if (keywords.length > 1) {
              keywords.push(searchText);
            }
            var resultItems = [];
            if (searchText.length > 0) {
              // perform local searching
              datas.forEach(function(data) {
                var isMatch = false;
                var hitCount = 0;
                var searchTextCount = 0;
                var title = data.title.trim();
                var titleInLowerCase = title.toLowerCase();
                var content = data.content.trim().replace(/<[^>]+>/g,"");
                var contentInLowerCase = content.toLowerCase();
                var articleUrl = decodeURIComponent(data.url);
                var indexOfTitle = [];
                var indexOfContent = [];
                // only match articles with not empty titles
                if(title != '') {
                  keywords.forEach(function(keyword) {
                    function getIndexByWord(word, text, caseSensitive) {
                      var wordLen = word.length;
                      if (wordLen === 0) {
                        return [];
                      }
                      var startPosition = 0, position = [], index = [];
                      if (!caseSensitive) {
                        text = text.toLowerCase();
                        word = word.toLowerCase();
                      }
                      while ((position = text.indexOf(word, startPosition)) > -1) {
                        index.push({position: position, word: word});
                        startPosition = position + wordLen;
                      }
                      return index;
                    }

                    indexOfTitle = indexOfTitle.concat(getIndexByWord(keyword, titleInLowerCase, false));
                    indexOfContent = indexOfContent.concat(getIndexByWord(keyword, contentInLowerCase, false));
                  });
                  if (indexOfTitle.length > 0 || indexOfContent.length > 0) {
                    isMatch = true;
                    hitCount = indexOfTitle.length + indexOfContent.length;
                  }
                }

                // show search results

                if (isMatch) {
                  // sort index by position of keyword

                  [indexOfTitle, indexOfContent].forEach(function (index) {
                    index.sort(function (itemLeft, itemRight) {
                      if (itemRight.position !== itemLeft.position) {
                        return itemRight.position - itemLeft.position;
                      } else {
                        return itemLeft.word.length - itemRight.word.length;
                      }
                    });
                  });

                  // merge hits into slices

                  function mergeIntoSlice(text, start, end, index) {
                    var item = index[index.length - 1];
                    var position = item.position;
                    var word = item.word;
                    var hits = [];
                    var searchTextCountInSlice = 0;
                    while (position + word.length <= end && index.length != 0) {
                      if (word === searchText) {
                        searchTextCountInSlice++;
                      }
                      hits.push({position: position, length: word.length});
                      var wordEnd = position + word.length;

                      // move to next position of hit

                      index.pop();
                      while (index.length != 0) {
                        item = index[index.length - 1];
                        position = item.position;
                        word = item.word;
                        if (wordEnd > position) {
                          index.pop();
                        } else {
                          break;
                        }
                      }
                    }
                    searchTextCount += searchTextCountInSlice;
                    return {
                      hits: hits,
                      start: start,
                      end: end,
                      searchTextCount: searchTextCountInSlice
                    };
                  }

                  var slicesOfTitle = [];
                  if (indexOfTitle.length != 0) {
                    slicesOfTitle.push(mergeIntoSlice(title, 0, title.length, indexOfTitle));
                  }

                  var slicesOfContent = [];
                  while (indexOfContent.length != 0) {
                    var item = indexOfContent[indexOfContent.length - 1];
                    var position = item.position;
                    var word = item.word;
                    // cut out 100 characters
                    var start = position - 20;
                    var end = position + 80;
                    if(start < 0){
                      start = 0;
                    }
                    if (end < position + word.length) {
                      end = position + word.length;
                    }
                    if(end > content.length){
                      end = content.length;
                    }
                    slicesOfContent.push(mergeIntoSlice(content, start, end, indexOfContent));
                  }

                  // sort slices in content by search text's count and hits' count

                  slicesOfContent.sort(function (sliceLeft, sliceRight) {
                    if (sliceLeft.searchTextCount !== sliceRight.searchTextCount) {
                      return sliceRight.searchTextCount - sliceLeft.searchTextCount;
                    } else if (sliceLeft.hits.length !== sliceRight.hits.length) {
                      return sliceRight.hits.length - sliceLeft.hits.length;
                    } else {
                      return sliceLeft.start - sliceRight.start;
                    }
                  });

                  // select top N slices in content

                  var upperBound = parseInt('1');
                  if (upperBound >= 0) {
                    slicesOfContent = slicesOfContent.slice(0, upperBound);
                  }

                  // highlight title and content

                  function highlightKeyword(text, slice) {
                    var result = '';
                    var prevEnd = slice.start;
                    slice.hits.forEach(function (hit) {
                      result += text.substring(prevEnd, hit.position);
                      var end = hit.position + hit.length;
                      result += '<b class="search-keyword">' + text.substring(hit.position, end) + '</b>';
                      prevEnd = end;
                    });
                    result += text.substring(prevEnd, slice.end);
                    return result;
                  }

                  var resultItem = '';

                  if (slicesOfTitle.length != 0) {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + highlightKeyword(title, slicesOfTitle[0]) + "</a>";
                  } else {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + title + "</a>";
                  }

                  slicesOfContent.forEach(function (slice) {
                    resultItem += "<a href='" + articleUrl + "'>" +
                      "<p class=\"search-result\">" + highlightKeyword(content, slice) +
                      "...</p>" + "</a>";
                  });

                  resultItem += "</li>";
                  resultItems.push({
                    item: resultItem,
                    searchTextCount: searchTextCount,
                    hitCount: hitCount,
                    id: resultItems.length
                  });
                }
              })
            };
            if (keywords.length === 1 && keywords[0] === "") {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>'
            } else if (resultItems.length === 0) {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>'
            } else {
              resultItems.sort(function (resultLeft, resultRight) {
                if (resultLeft.searchTextCount !== resultRight.searchTextCount) {
                  return resultRight.searchTextCount - resultLeft.searchTextCount;
                } else if (resultLeft.hitCount !== resultRight.hitCount) {
                  return resultRight.hitCount - resultLeft.hitCount;
                } else {
                  return resultRight.id - resultLeft.id;
                }
              });
              var searchResultList = '<ul class=\"search-result-list\">';
              resultItems.forEach(function (result) {
                searchResultList += result.item;
              })
              searchResultList += "</ul>";
              resultContent.innerHTML = searchResultList;
            }
          }

          if ('auto' === 'auto') {
            input.addEventListener('input', inputEventFunction);
          } else {
            $('.search-icon').click(inputEventFunction);
            input.addEventListener('keypress', function (event) {
              if (event.keyCode === 13) {
                inputEventFunction();
              }
            });
          }

          // remove loading animation
          $(".local-search-pop-overlay").remove();
          $('body').css('overflow', '');

          proceedsearch();
        }
      });
    }

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched === false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };
    });

    $('.popup-btn-close').click(onPopupClose);
    $('.popup').click(function(e){
      e.stopPropagation();
    });
    $(document).on('keyup', function (event) {
      var shouldDismissSearchPopup = event.which === 27 &&
        $('.search-popup').is(':visible');
      if (shouldDismissSearchPopup) {
        onPopupClose();
      }
    });
  </script>





  

  
<script>
(function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';        
    }
    else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>


  

  

  

  

</body>
</html>
